home *** CD-ROM | disk | FTP | other *** search
- unit uFolderProps;
-
- {
- *******************************************************************************
- * Descriptions: Implementation for Explorer properties click
- * $Source: /cvsroot/fma/fma/uFolderProps.pas,v $
- * $Locker: $
- *
- * Todo:
- * - use notebook in general page
- *
- * Change Log:
- * $Log: uFolderProps.pas,v $
- * Revision 1.11.6.1 2005/01/25 16:03:08 z_stoichev
- * Merged with 2.1 Beta 1 bugfixes
- *
- * Revision 1.11 2004/08/17 14:47:02 merijnb
- * added support for sub-dirs for preview
- *
- * Revision 1.10 2004/06/28 14:01:29 z_stoichev
- * Bugfixes and common General page.
- * Added bookmark editing support.
- *
- * Revision 1.9 2004/06/17 12:42:17 z_stoichev
- * Fixed Unicode
- *
- * Revision 1.8 2004/05/19 18:34:15 z_stoichev
- * Build 0.1.0.35c
- *
- * Revision 1.7 2004/03/26 18:37:39 z_stoichev
- * Build 0.1.0.35 RC5
- *
- * Revision 1.6 2004/03/08 12:54:22 z_stoichev
- * Phone number - msg/call contact
- * Autoupdate phone details every 1 sec
- *
- * Revision 1.5 2003/12/16 17:38:05 z_stoichev
- * Refresh gives error when folder does not exists.
- *
- * Revision 1.4 2003/12/11 14:55:24 z_stoichev
- * Fixed Explorer properties visual bug issues.
- * Phone properties now shown more phone information.
- *
- * Revision 1.3 2003/12/11 12:41:02 z_stoichev
- * Refresh obex file implemented.
- *
- * Revision 1.2 2003/11/28 09:38:07 z_stoichev
- * Merged with branch-release-1-1 (Fma 0.10.28c)
- *
- * Revision 1.1.2.4 2003/11/13 16:39:54 z_stoichev
- * Add more items type support.
- *
- *
- *
- }
-
- interface
-
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, ComCtrls, ExtCtrls, TntComCtrls, TntStdCtrls,
- GR32_Image, MPlayer, OKTThemeEngine;
-
- const
- fpNone = 0;
- fpPhone = 1;
- fpContact = 2;
- fpBookmark = 3;
- fpDB = 4;
-
- type
- TfrmFolderProps = class(TForm)
- ApplyButton: TButton;
- PageControl1: TPageControl;
- TabSheet1: TTabSheet;
- Image1: TImage;
- TntEdit1: TTntEdit;
- TabSheet3: TTabSheet;
- PicPanel1: TPanel;
- SelImage: TImage32;
- MediaPlayer1: TMediaPlayer;
- Label1: TLabel;
- lblType: TLabel;
- lblNoCache: TLabel;
- btnDownload: TButton;
- lblNote: TLabel;
- Label3: TLabel;
- Timer1: TTimer;
- ThemeViewer1: TOKTThemeViewer;
- ThemeContainer1: TOKTThemeContainer;
- btnSS: TButton;
- cbPreview: TComboBox;
- SaveDialog1: TSaveDialog;
- lblLocalFile: TLabel;
- lblName: TTntLabel;
- Button3: TButton;
- NotebookPanel: TPanel;
- Notebook1: TNotebook;
- Label13: TLabel;
- Label12: TLabel;
- lbModel: TLabel;
- lbManufacturer: TLabel;
- Label14: TLabel;
- Label16: TLabel;
- lbSWRevision: TLabel;
- lbSerialNumber: TLabel;
- Label4: TLabel;
- Label5: TLabel;
- Label6: TLabel;
- lbvbat: TLabel;
- lbicharge: TLabel;
- lbcyclescharge: TLabel;
- Label7: TLabel;
- lbdcio: TLabel;
- lbiphone: TLabel;
- Label8: TLabel;
- Label9: TLabel;
- lblTimeLeft: TLabel;
- Label10: TLabel;
- Label11: TLabel;
- lbtempphone: TLabel;
- lbtempbatt: TLabel;
- lblContact: TTntLabel;
- Button1: TButton;
- Button2: TButton;
- lblBookmark: TLabel;
- edBookmark: TEdit;
- Label2: TLabel;
- Memo1: TMemo;
- lblDB: TLabel;
- Bevel1: TBevel;
- procedure FormCreate(Sender: TObject);
- procedure FormShow(Sender: TObject);
- procedure MediaPlayer1Click(Sender: TObject; Button: TMPBtnType;
- var DoDefault: Boolean);
- procedure btnDownloadClick(Sender: TObject);
- procedure Timer1Timer(Sender: TObject);
- procedure cbPreviewChange(Sender: TObject);
- procedure btnSSClick(Sender: TObject);
- private
- Filetype: integer;
- Fullpath: string;
- FRootNode: TtntTreeNode;
- FBookmarkIndex: integer;
- FBookmarkIndexPhone: integer;
- procedure Set_RootNode(const Value: TtntTreeNode);
- { Private declarations }
- procedure UpdatePhoneDetails;
- function Get_BmUrl: string;
- function Get_BmTtl: WideString;
- public
- { Public declarations }
- property RootNode: TtntTreeNode read FRootNode write Set_RootNode default nil;
- //
- property BookmarkPhoneIndex: integer read FBookmarkIndexPhone;
- property BookmarkDataIndex: integer read FBookmarkIndex;
- property BookmarkURL: string read Get_BmUrl;
- property BookmarkTitle: WideString read Get_BmTtl;
- end;
-
- var
- frmFolderProps: TfrmFolderProps;
-
- implementation
-
- uses Unit1, uGlobal;
-
- {$R *.dfm}
-
- procedure TfrmFolderProps.Set_RootNode(const Value: TtntTreeNode);
- var
- id: Integer;
- sl: TStringList;
- i: integer;
- begin
- Notebook1.PageIndex := fpNone;
-
- FRootNode := Value;
- if Value = nil then begin
- Memo1.Visible := False;
- lblDB.Visible := False;
- exit;
- end;
-
- { Allow phone rename if connected and root is selected }
- if Value = Form1.Explorer.Items[0] then begin
- TntEdit1.Visible := True;
- TntEdit1.Text := Value.Text;
- { Get phone info }
- UpdatePhoneDetails;
- Notebook1.PageIndex := fpPhone;
- end;
-
- if not Visible then begin // will be executed at least one (first time)
- lblName.Caption := Value.Text;
- Memo1.Lines.Clear;
- Memo1.Visible := True;
- lblDB.Visible := True;
- id := Value.StateIndex;
-
- if Form1.PhoneIdentity <> '' then
- Fullpath := ExePath+'data\'+Form1.PhoneIdentity+'\dat\'
- else
- Fullpath := ExePath;
-
- // Contacts
- if (id and $F00000) = $100000 then begin
- Memo1.Lines.Add(Fullpath+'Contacts.ME.dat');
- Memo1.Lines.Add(Fullpath+'Contacts.SM.dat');
- Memo1.Lines.Add(Fullpath+'Contacts.SYNC.dat');
- Memo1.Lines.Add(Fullpath+'Contacts.SYNCMAX.dat');
- Memo1.Lines.Add(Fullpath+'ContactSync.xml');
- end;
- // Messages
- if (id and $F00000) = $200000 then begin
- Memo1.Lines.Add(Fullpath+'SMSInbox.dat');
- Memo1.Lines.Add(Fullpath+'SMSOutbox.dat');
- Memo1.Lines.Add(Fullpath+'SMSSent.dat');
- Memo1.Lines.Add(Fullpath+'SMSArchive.dat');
- end;
- // Organizer
- if (id and $F00000) = $300000 then begin
- Memo1.Lines.Add(Fullpath+'Bookmarks.dat');
- end;
- // Files, Profiles, Groups
- if ((id and $F00000) = $500000) or ((id and $F00000) = $700000) or ((id and $F00000) = $800000) then begin
- Memo1.Lines.Add('Dynamic Data');
- Memo1.Lines.Add('(will be loaded from phone when connected)');
- end;
-
- // Phones
- if Value.ImageIndex in [9..13] then begin
- lblContact.Caption := Value.Parent.Text;
- Notebook1.PageIndex := fpContact;
- end;
-
- edBookmark.Text := '';
- if Value.ImageIndex = 59 then begin
- sl := TStringList(Form1.FNodeBookmarks.Data);
- i := 0;
- while (i < sl.Count) do begin
- if StrToInt(GetToken(sl[i],0)) = id then begin
- FBookmarkIndex := i;
- FBookmarkIndexPhone := id;
- break;
- end;
- inc(i);
- end;
- if i < sl.Count then begin
- edBookmark.Text := GetToken(sl[i],1);
- TntEdit1.Visible := True;
- TntEdit1.Text := Value.Text;
- Notebook1.PageIndex := fpBookmark;
- end;
- end;
-
- if Memo1.Lines.Count <> 0 then begin
- Notebook1.PageIndex := fpDB;
- end;
- NotebookPanel.Visible := Notebook1.PageIndex <> fpNone;
- end;
-
- if TabSheet3.TabVisible then begin
- Filetype := -1;
- id := Form1.ExplorerFindExtImage(ExtractFileExt(Value.Text));
- try
- lblLocalFile.Caption := '';
- case id of
- 36: // sound
- begin
- Fullpath := ExePath+'data\'+Form1.PhoneIdentity+'\snd\'+Value.Text;
- if FileExists(Fullpath) then begin
- lblNoCache.Caption := 'cached localy';
- MediaPlayer1.FileName := Fullpath;
- MediaPlayer1.Open;
- MediaPlayer1.Enabled := True;
- MediaPlayer1.Visible := True;
- lblLocalFile.Caption := Fullpath;
- end
- else
- lblNoCache.Caption := 'stored in phone';
- btnDownload.Visible := True;
- btnDownload.Enabled := True;
- lblType.Caption := 'sound';
- Filetype := 1;
- end;
- 37: // image
- begin
- Fullpath := ExePath+'data\'+Form1.PhoneIdentity+'\pic\'+Value.Text;
- if FileExists(Fullpath) then begin
- lblNoCache.Caption := 'cached localy';
- SelImage.Bitmap.LoadFromFile(Fullpath);
- SelImage.Visible := True;
- lblLocalFile.Caption := Fullpath;
- end
- else
- lblNoCache.Caption := 'stored in phone';
- btnDownload.Visible := True;
- btnDownload.Enabled := True;
- PicPanel1.Visible := True;
- lblType.Caption := 'picture';
- Filetype := 0;
- end;
- 27: // theme
- begin
- Fullpath := ExePath+'data\'+Form1.PhoneIdentity+'\thm\'+Value.Text;
- if FileExists(Fullpath) then begin
- lblNoCache.Caption := 'cached localy';
- ThemeContainer1.OpenTheme(Fullpath);
- lblLocalFile.Caption := Fullpath;
- ThemeViewer1.Preview := pvStandby;
- ThemeViewer1.Visible := True;
- cbPreview.ItemIndex := Ord(pvStandby)-1;
- cbPreview.Visible := True;
- btnSS.Visible := True;
- end
- else
- lblNoCache.Caption := 'stored in phone';
- btnDownload.Visible := True;
- btnDownload.Enabled := True;
- lblType.Caption := 'theme';
- Filetype := 2;
- end;
- end;
- except
- lblNoCache.Caption := 'file damaged, or unknown format';
- btnDownload.Visible := True;
- btnDownload.Enabled := True;
- end;
- if not PicPanel1.Visible and not MediaPlayer1.Visible and (Filetype = -1) then begin
- TabSheet3.TabVisible := False;
- end;
- end;
- end;
-
- procedure TfrmFolderProps.FormCreate(Sender: TObject);
- begin
- {$IFNDEF VER150}
- Form1.ThemeManager1.CollectForms(Self);
- {$ENDIF}
- end;
-
- procedure TfrmFolderProps.FormShow(Sender: TObject);
- begin
- PageControl1.ActivePageIndex := 0;
- end;
-
- procedure TfrmFolderProps.MediaPlayer1Click(Sender: TObject;
- Button: TMPBtnType; var DoDefault: Boolean);
- begin
- if Button = btStop then MediaPlayer1.Rewind;
- end;
-
- procedure TfrmFolderProps.btnDownloadClick(Sender: TObject);
-
- function ExtractDir(Node: TTntTreeNode): string;
- var ImageIndex: integer;
- begin
- Node := Node.Parent; // start at parent of 'file node'
- Imageindex := Node.ImageIndex;
-
- while assigned(Node) and (Node.ImageIndex = ImageIndex) do
- begin
- result := Node.Text + '/' + result;
- Node := Node.Parent;
- end;
-
- if (Length(Result) > 1) and (Result[Length(Result)] = '/') then
- SetLength(Result, Length(Result) - 1);
- end;
-
- begin
- btnDownload.Enabled := False;
- try
- MediaPlayer1.Close;
- ForceDirectories(ExtractFileDir(Fullpath));
- Form1.ObexGetFile(Fullpath,{Form1.FindObexFolderName(Filetype)}ExtractDir(RootNode) +'/'+ExtractFileName(Fullpath));
- RootNode := RootNode; // force update of screen
- finally
- btnDownload.Enabled := True;
- end;
- end;
-
- procedure TfrmFolderProps.UpdatePhoneDetails;
- begin
- lbManufacturer.Caption := Form1.frmInfoView.lbManufacturer.Caption;
- lbModel.Caption := Form1.frmInfoView.lbModel.Caption;
- lbSWRevision.Caption := Form1.frmInfoView.lbSWRevision.Caption;
- lbSerialNumber.Caption := Form1.frmInfoView.lbSerialNumber.Caption;
- lbvbat.Caption := Form1.frmInfoView.lbvbat.Caption;
- lbicharge.Caption := Form1.frmInfoView.lbicharge.Caption;
- lbcyclescharge.Caption := Form1.frmInfoView.lbcyclescharge.Caption;
- lbdcio.Caption := Form1.frmInfoView.lbdcio.Caption;
- lbiphone.Caption := Form1.frmInfoView.lbiphone.Caption;
- lblTimeLeft.Caption := Form1.frmInfoView.lblTimeLeft.Caption;
- lbtempbatt.Caption := Form1.frmInfoView.lbtempbatt.Caption;
- lbtempphone.Caption := Form1.frmInfoView.lbtempphone.Caption;
- Timer1.Enabled := True;
- end;
-
- procedure TfrmFolderProps.Timer1Timer(Sender: TObject);
- begin
- UpdatePhoneDetails;
- end;
-
- procedure TfrmFolderProps.cbPreviewChange(Sender: TObject);
- begin
- ThemeViewer1.Preview := TOKTPreview(cbPreview.ItemIndex+1);
- end;
-
- procedure TfrmFolderProps.btnSSClick(Sender: TObject);
- begin
- SaveDialog1.FileName := ChangeFileExt(lblName.Caption,'') + ' - ' + cbPreview.Text + '.bmp';
- if SaveDialog1.Execute then
- ThemeViewer1.ScreenShot.SaveToFile(SaveDialog1.FileName);
- end;
-
- function TfrmFolderProps.Get_BmUrl: string;
- begin
- Result := edBookmark.Text;
- end;
-
- function TfrmFolderProps.Get_BmTtl: WideString;
- begin
- Result := TntEdit1.Text;
- end;
-
- end.
-